import KZJRequest from '../index'
import { TRequestDefaultResult } from '../type'

enum Video {
  Titles = '/video/group/list', // 标题
  Group = '/video/group',
  All = '/mv/all',
  Comment = '/comment/video',
  Detail = '/video/detail', // 详情
  DetailInfo = '/video/detail/info', // 点赞等数据
  Url = '/video/url', // 播放地址
  Simi = '/related/allvideo' // 相关视频
}

export function getTitles() {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.Titles,
    takeCookie: false
  })
}

export function getGroup(id: number, offset: number) {
  return KZJRequest.post<TRequestDefaultResult>({
    url: Video.Group,
    data: { id, offset },
    takeCookie: true
  })
}

export function getAllData(area = '内地', limit = 20, offset = 0) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.All,
    params: { area, limit, offset },
    showLoading: true,
    takeCookie: false
  })
}

export function getViComment(id: string, limit = 20, offset = 0) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.Comment,
    params: { id, limit, offset },
    showLoading: true,
    takeCookie: false
  })
}

export function getViDetail(id: string) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.Detail,
    params: { id },
    showLoading: true,
    takeCookie: false
  })
}

export function getViDetailInfo(vid: string) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.DetailInfo,
    params: { vid },
    showLoading: true,
    takeCookie: false
  })
}

export function getViUrl(id: string) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.Url,
    params: { id },
    showLoading: true,
    takeCookie: false
  })
}

export function getViSimi(id: string) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Video.Simi,
    params: { id },
    showLoading: true,
    takeCookie: false
  })
}
